import requests
from lxml import etree
import pandas as pd
import numpy as np
import time
import json
params = {
    "offset": 0,
    "limit": 100,
    "platform": "website",
    "t": "1683274098516"
}

data_headers = {'User-Agent': 'Mozilla/5.0(Windows;U;Windows NT6.1;en-US;rv:1.9.1.6) Geko/20091201 Firefox/3.5.6'}
url = 'https://yobang.tencentmusic.com/unichartsapi/v1/songs/charts/dynamic'
r = requests.get(url, headers=data_headers, timeout=1,params=params).content.decode('utf-8')
res = json.loads(r)
charts_list = res['data']['chartsList']
for chart in charts_list:
    rank = '排名' + str(chart['rank'])
    uni_index = '综合得分'+str(chart['uniIndex'])
    song_name = '歌曲名称'+str(chart['songName'])
    publish_time = '发行时间'+str(chart['publishTime'])
    singer_name = '歌手'+str(chart['singerName'])
    track_tags = '标签'+str(chart['trackTags'])
    track_publish_weeks = '据发行多少周'+str(chart['trackPublishWeeks'])
    on_chart_weeks = '在榜周数'+str(chart['onChartWeeks'])
    history_highest_rank = '历史最高排名'+str(chart['historyHighestRank'])
    print(rank + ", " + uni_index+ ", " + song_name)